<?php
use think\Controller;

class Api  {
	
	//新令牌
    private  $token;
	
	/**
    * 构造函数自动执行
    * @return null
    */
    public function __construct($token=null){
    	$this ->token =  $token;
    }

	/**
     * 获取示例
     * @param array $options 实例配置
     * @return static
     */
    public static function instance($token=null)
    {
        return new self($token);
    }
	
	/**
    * 返回操作成功json
    * @param string $msg
    * @param string $url
    * @param array $data
    * @return array
    */
	public static function ReSucess ( $data = "", $msg = "操作成功", $code = 0 ){
		$array = array();
		$array["code"] = $code;
		$array["data"] = $data;
		$array["msg"] = $msg;
		return json($array);
	}
	
	/**
    * 返回操作失败json
    * @param string $msg
    * @param string $title
    * @param array $data
    * @return array
    */
	public  static function ReError ( $msg = "错误！",$code=-1, $data=[]){
		$array = array();
		$array["code"] = $code;
		$array["data"] = $data;
		$array["msg"] = $msg;
		return json($array);
	}
	
}